package taliav3;

/**
 *
 *
 * Klasa pomocnicza
 * Dzieki statycznym metodom dodawanie zdarzen,
 * okreslanie wymiarow i obrazka jest bardziej czytelne
 * zajmuje mniej linjek kodu.
 */

import javax.swing.JLabel;
import javax.swing.ImageIcon;
import java.net.URL;
import java.awt.event.*;
import java.awt.Font;

public class Labels {

    /** setting label (JLabel object) in bounds (X,Y,width,height) with specified imagefile (path stored in String path)
     * and adding MouseAdapter listener*/
    public static void setLabel(JLabel label, int X, int Y, int width, int height, String path, MouseAdapter adapter)
    {
        URL urlToImage = Labels.class.getResource(path);
        label.setIcon((new ImageIcon(urlToImage)));
        label.setBounds(X, Y, width, height);
        label.addMouseListener(adapter);
    }
    /** setting label (JLabel object) in bounds (X,Y,width,height) with specified imagefile (path stored in String path)*/
    public static void setLabel(JLabel label, int X, int Y, int width, int height, String path)
    {
        URL urlToImage = Labels.class.getResource(path);
        label.setIcon((new ImageIcon(urlToImage)));
        label.setBounds(X, Y, width, height);
    }
    /** setting label (JLabel object) in bounds (X,Y,width,height) with specified imagefile (path stored in String path)
     * and adding MouseAdapter listener, MouseMotion listener*/
    public static void setLabel(JLabel label, int X, int Y, int width, int height, String path, MouseAdapter adapter, MouseMotionListener adapter1)
    {
        URL urlToImage = Labels.class.getResource(path);
        label.setIcon((new ImageIcon(urlToImage)));
        label.setBounds(X, Y, width, height);
        label.addMouseListener(adapter);
        label.addMouseMotionListener(adapter1);
    }
    /** setting label (JLabel object) in bounds (X,Y,width,height) with specified Text (String text) and Font (Font font)*/
    public static void setLabel(JLabel label, int X, int Y, int width, int height, String text, Font font)
    {
        label.setBounds(X, Y, width, height);
        label.setFont(font);
        label.setText(text);
    }
}
